import { PollMtEntity, perPollEitity } from '@/pages/create/createContent/blocks/poll/interface'
import requestMeeting, { request } from '@/plugins/axios'
/** 获取轮询预案列表 */
export const fetchGetPollPlanList = async (url: string) =>
	requestMeeting<Array<perPollEitity>>({
		url: url,
		method: 'GET',
	}).then((res) => res)

/**获取模板轮询预案信息 */
export const fetchGetPollPlan = async (is_templete: boolean, pre_key: string, id: string) =>
	request<PollMtEntity>({
		url: `/${is_templete ? 'personal_templates' : 'meetings'}/${pre_key}/prepolls/${id}`,
		method: 'get',
	}).then((res) => res)

/**保存預案 */
export const fetchSavePollPlan = async (is_templete: boolean, pre_key: string, params: Partial<PollMtEntity>) =>
	requestMeeting<string>({
		url: `/${is_templete ? 'personal_templates' : 'meetings'}/${pre_key}/prepolls`,
		method: 'post',
		data: params,
	}).then((res) => res)

/**修改預案 */
export const fetchUpdatePollPlan = async (
	is_templete: boolean,
	pre_key: string,
	id: string,
	params: Partial<PollMtEntity>
) =>
	requestMeeting<string>({
		url: `/${is_templete ? 'personal_templates' : 'meetings'}/${pre_key}/prepolls/${id}`,
		method: 'post',
		data: params,
	}).then((res) => res)
/** 刪除轮询预案 */
export const fetchDeletePlan = async (is_templete: boolean, pre_key: string, id: string) =>
	requestMeeting({
		url: `/${is_templete ? 'personal_templates' : 'meetings'}/${pre_key}/prepolls/${id}`,
		method: 'DELETE',
	}).then((res) => res)
